#include <cstddef>

#include "configuration.h"

Configuration* Configuration::instance = NULL;

Configuration::Configuration()
{
    Configuration(XML);
}

Configuration::Configuration(DataType dt)
{
    services["BasePath"] = "http://api.t.sina.com.cn/";
    if(dt==XML)
    {
        services["DataTypePostfix"] = ".xml";
        this->dt = dt;
    }
    else
    {
        services["DataTypePostfix"] = ".json";
        this->dt = dt;
    }
    services["AppKey"] = "";
    services["AppSecret"] = "";
    services["FriendsTimeline"] = services["BasePath"] + "statuses/friends_timeline" + services["DataTypePostfix"];
    services["VerifyCredentials"] = services["BasePath"] + "account/verify_credentials" + services["DataTypePostfix"];
    services["Mentions"] = services["BasePath"] + "statuses/mentions" + services["DataTypePostfix"];
    services["MyTimeline"] = services["BasePath"] + "statuses/user_timeline" + services["DataTypePostfix"];
    services["OthersTimeline"] = services["BasePath"] + "statuses/user_timeline/%1" + services["DataTypePostfix"];
    services["Favorites"] = services["BasePath"] + "favorites" + services["DataTypePostfix"];
    services["CommentsTimeline"] = services["BasePath"] + "statuses/comments_timeline" + services["DataTypePostfix"];
    services["Update"] = services["BasePath"] + "statuses/update" + services["DataTypePostfix"];
    services["Upload"] = services["BasePath"] + "statuses/upload" + services["DataTypePostfox"];
    services["Emotions"] = services["BasePath"] + "emotions" + services["DataTypePostfox"];
    services["Repost"] = services["BasePath"] + "statuses/repost" + services["DataTypePostfox"];
    services["Comment"] = services["BasePath"] + "statuses/comment" + services["DataTypePostfox"];
    services["AddFavorite"] = services["BasePath"] + "favorites/create" + services["DataTypePostfox"];
    services["Unread"] = services["BasePath"] + "statuses/unread" + services["DataTypePostfox"];
    services["ResetCount"] = services["BasePath"] + "statuses/reset_count" + services["DataTypePostfox"];
    services["DirectMessages"] = services["BasePath"] + "direct_messages" + services["DataTypePostfox"];
    services["CommentReply"] = services["BasePath"] + "statuses/reply" + services["DataTypePostfox"];
    services["DeleteFavorite"] = services["BasePath"] + "favorites/destroy/%1" + services["DataTypePostfox"];
    services["DeleteStatus"] = services["BasePath"] + "statuses/destroy/%1" + services["DataTypePostfox"];
    services["SendDirectMessage"] = services["BasePath"] + "direct_messages/new" + services["DataTypePostfox"];
    services["Counts"] = services["BasePath"] + "statuses/counts" + services["DataTypePostfox"];
    services["Comments"] = services["BasePath"] + "statuses/comments" + services["DataTypePostfox"];
    services["RequestTokenV1"] = services["BasePath"] + "oauth/authorize";
    services["AuthorizeV1"] = services["BasePath"] + "oauth/authorize";
    services["AccessToken"] = services["BasePath"] + "oauth/access_token";
}

Configuration* Configuration::getInstance()
{
    if (instance == NULL)
    {
        instance = new Configuration();
    }
    return instance;
}

Configuration::DataType Configuration::getDataType()
{
    return Configuration::getInstance()->dt;
}
